Jes.extend(Jes.Upload,{
	//upload.html上传页面
	init : function(){//页面初始化
		var req = Jes.req(),type=req.type || 'BUSS';
		req.type=type;
		if(type=='img') Jes.html('tit','图片上传');
		else if(type=='video') Jes.html('tit','视频上传');
		if(req.cs==1) Jes.html('picinfo','是否压缩<input type="checkbox" id="isC" name="isC" class="checkbox" value="1"/>(不压缩请设置图片大小[宽'+req.w+'-高'+req.h+']象素)')
		upform.action='../upload.shtml'.J(req);
	}
	,upload : function(){
		var req = Jes.req(),upId=req.upId,num=req.num,_len = Jes.opener().Jes.names(upId+'.upname').length,type=req.type
		,name =type=='img'?'图片':(type=='video'?'视频':'附件'),file = Jes('upfile').value;
		//附件NUM限制
		if(num && num <=_len){alert('上传'+name+'不能超过'+num+"项");return;}
		if(file == ''){alert('上传'+name+'不能为空');return;}
		if(type=='img' && !file.isPic()){alert('上传图片格式必须是jpg或者gif');return;}
		Jes.show('pBar');
		Jes.html('pBTxt','上传进度: 0%');
    	Jes("pBBCont").style.width = "0px";
    	Jes.disBtn();
    	window.setTimeout("Jes.Upload._proc()", 1000);
    	//return true;
		upform.submit();
	}
	,again : function(){
		Jes('upfile').outerHTML  = Jes('upfile').outerHTML;
		Jes.hide('pBar');
	}
	,_proc : function(){
		Jes.action("getINFO","UPPROC",function(da){
	    	if(da){
	    		Jes.html("pBTxt",da.procInfo);
	    		Jes("pBBCont").style.width = parseInt(da.procPer * 2.16)+"px";
	    	}
			if (!da || da.isProcess){
				window.setTimeout("Jes.Upload._proc()", 100);
			}else{
				Jes("pBBCont").style.width = "216px";
				var h='<input type="button" value="继续上传" onclick="Jes.Upload.again();"/>&nbsp;&nbsp;';
				if(Jes.req('num')==1) h='';
				Jes.html('pBTxt','<p><font color="red">'+da.procInfo+'</font></p><p>'+h+'<input type="button" value="关 闭" onclick="Jes.close();"/></p>');
				//Jes.hide("eBar");
				Jes.disBtn(false);
			}
	    });
	}
	//upload_response.jsp
	,cb : function(da){
		var req = Jes.req(),upId=req.upId,cb=req.cb,cbEl=req.cbEl,_opener = Jes.opener(),taEl=_opener.Jes(upId),tr,td;
		if(cb){
			eval('_opener.'+cb+'(da);');
		}else{
			try{
				if(req.type=='img' && 'gif|jpg'.indexOf(da.type) != -1){
					var style = Jes.isN(req.w)?'':' width="'+req.w+'" height="'+req.h+'"';
					tr = Jes.tr(taEl);
					td = Jes.td(tr,'<img src="'+da.httppath+'img/'+da.name +'" '+style+'><input type="hidden" id="'+upId+'.upname" name="'+upId+'.upname" value="'+da.name+'"/>',{align:'center'});
					td = Jes.td(tr,'<input type="button" value="删除" style="border:1px soild #000000;font-size:10px;" onclick="Jes.Upload.del(this,\''+da.id+'\',\''+da.name+'\',\''+cbEl+'\');"/>',{align:'center'});
					if(cbEl) _opener.Jes.val(cbEl,da.name);
				}else{
					tr = Jes.tr(taEl);
					td = Jes.td(tr,'<a href="../../download.shtml?name='+da.name+'&oldName='+da.oldname+'&isTemp=true">'+da.oldname+'</a>',{align:'center',height:'30px',bgColor:'#ffffff'});
					td = Jes.td(tr,da.upsize);
					td = Jes.td(tr,Jes.curDate());
					td = Jes.td(tr,'<input type="button" value="删除" style="border:1px soild #000000;font-size:10px;" onclick="Jes.Upload.del(this,\''+da.id+'\',\''+da.name+'\');"/>');
				}
		    }catch(e){
				alert("获得附件信息失败，请联系管理员。");
			}
		}
	}
});
